package BehavioralMode.interpreter.calculator;

/**
 * 解释器模式客户端
 * */
public class Client {

    public static void main(String[] args) {
        Variable a = new Variable("a");
        Variable b = new Variable("b");
        Variable c = new Variable("c");
        Variable d = new Variable("d");

        Context context = new Context();
        context.put(a,1);
        context.put(b,1);
        context.put(c,1);
        context.put(d,1);

        // a+b-c+d
        AbstractExpression abstractExpression = new AddExpression(new SubExpression(new AddExpression(a,b),c),d);
        int res = abstractExpression.interpret(context);
        System.out.println(res);


    }
}

